package assist.datastore.parser;

import assist.domain.model.BlockedShot;
import assist.domain.model.Event;
import assist.domain.model.Faceoff;
import assist.domain.model.GameTime;
import assist.domain.model.Goal;
import assist.domain.model.MissedShot;
import assist.domain.model.Penalty;
import assist.domain.model.ShotOnGoal;

public class NHLEventFactory
{
    /**
     * Takes the parsed Event event data and creates an Event domain object.
     * @param eventType
     * @param period
     * @param time
     * @return The Event object created.
     */
    static Event createEvent(String eventType, final Integer period, final String time)
    {
        Event event = null;
        eventType = eventType.toUpperCase();
         
        if ("SHOT".equals(eventType))
        {
            event = new ShotOnGoal(); 
        }
        else if ("MISS".equals(eventType))
        {
            event = new MissedShot();
        }
        else if ("GOAL".equals(eventType))
        {
            event = new Goal();
        }
        else if ("BLOCK".equals(eventType))
        {
            event = new BlockedShot();
        }
        else if ("PENL".equals(eventType))
        {
            event = new Penalty();
        }       
        else if ("FAC".equals(eventType))
        {
            event = new Faceoff();
        }        
        if (event == null)
        {
            return null;
        }
                
        final GameTime gameTime = 
            GameTime.create(period, time);
        event.setGameTime(gameTime);
        return event;
    }
}
